<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>

        // parseInt()  取整   从第一位开始，取数字部分，遇到非数字就结束
        // parseFloat()  取浮点数

        var a = '24.45px24';
        console.log(a);
        console.log(parseInt(a));   // 24

        var b = '24.45.45px24';
        console.log(parseFloat(b));  // 24.45


        var c = 3.14;
        console.log(parseInt(c));  // 3


    </script>

</body>

</html>